realmcrafterfandomcom-20200216-history
Petition Reader Script
Created by Taz. Using "RC_Core.rcm" ; By Naddaz on TAZCO Function Main() ;GM petition reader ;Need to add a rank check for the delete option. ;Can look at a list of names that made the petitions and then input a name to look at ;there petition. ;Right now any gm will be able to run this. Player = Actor() Target = Contextactor() PGmRank$ = Attribute(Player, "Gm Rank") ;Player GM Rank check. If (PlayerIsGM(Player)) ;check if player is a gm will change to gm rank If (PGmRank <= 2) ;if gm is rank is <= 2 , don`t allow them to read petitions OutPut(Player, "You need a GM rank of 3 or higher to uses this command.") Return Endif ChatBox$ = OpenDialog(Player, Target, "GM Petition Reader") DialogOutPut(Player, ChatBox, "What would you like to do?", 230, 145, 23) GMOption$ = DialogInPut(Player, ChatBox, "Look for petition,Count players in list") ; can add more options here later. If (GmOption = 1) ;Check if there is any petitions available to look at. DialogOutPut(Player, Chatbox, "Please type the name of the player, to see there petition.", 230, 145, 23) PetEnter$ = Input(Player, "Enter name of player", "", 4) PetList$ = OpenFile("Petition List.txt") Repeat Nameinlist$ = ReadLine(PetList) DoEvents(10) EndRepeat = Eof(PetList) OutPut(Player, "Name in list " + Nameinlist, 230, 145, 23) If (Nameinlist = PetEnter) EndRepeat% = 0 Eof(PetList) CloseFile(Nameinlist) Endif Until (EndRepeat = 0) CloseFile(PetList) If (Nameinlist = "") ; there is nothing in the list. DialogOutPut(Player, ChatBox, "There is no name in the list.", 230, 145, 23) Dialoginput(Player, ChatBox, "Close") CloseDialog(Player, ChatBox) Return Else ;there is a name in the list, check for file based on that name. ;NOTE will need to add in a count to see how many lines there is in the petition file. ;then tell gm and give an option to pick a line to read. CloseDialog(Player, ChatBox) ChatBox$ = OpenDialog(Player, Target, "GM Petition Reader") PetFile$ = OpenFile(+ PetEnter + "s petition.txt") If (PetFile = 0) DialogOutPut(Player, ChatBox, "There is no one in the list by that name.", 230, 145, 23) DialogInPut(Player, ChatBox, "Close") CloseDialog(Player, ChatBox) CloseFile(PetFile) Return Endif PetPlay2$ = ReadFile(+ PetEnter + "s petition.txt") PetPlay$ = Readline(PetPlay2) CloseFile(PetPlay2) CloseFile(PetFile) DialogOutPut(Player, ChatBox, "Would you like to see this petition?", 230, 145, 23) POption% = DialogInput(Player, ChatBox, "Yes,No") If (POption = 1) ;show petition DialogOutPut(Player, ChatBox, + PetPlay, 230, 145, 23) ;NOTE COuld add a gm rank to this so that only high gms can delete petitions. GmOption$ = DialogInput(Player, ChatBox, "Close Leave petition,Delete petition") If (GmOption = 1) ;leave petition in server. Elseif (GmOption = 2) ;delete petition DialogOutPut(Player, ChatBox, "ARE YOU SURE YOU WANT TO DELETE " + PetEnter + " PETITION?", 255, 0, 0) GmOption1$ = DialogInput(player, ChatBox, "Yes,No") If (GmOption1 = 1) ;delete petition DeleteFile(+ PetEnter + "s petition.txt") OutPut(Player, + PetEnter + "s petition.txt", 255, 23,13) DialogOutPut(Player,ChatBox, "You have deleted a petiton.", 230, 145, 23) DialogInput(Player, ChatBox, "Close") CloseDialog(Player, ChatBox) Return Else ;Exit script DoEvents(400) CloseDialog(Player, ChatBox) Return Endif Endif CloseDialog(Player, ChatBox) Return Else ; close this dialog DoEvents(500) CloseDialog(Player, ChatBox) Return Endif DialogInput(Player, ChatBox, "Close") CloseDialog(Player, ChatBox) Endif CloseFile(PetList) ElseIf (GMOption = 2) ;Count players in list. ;Count players in the Petition list text file to output how many people there are. CloseDialog(Player, ChatBox) ChatBox$ = OpenDialog(Player, Target, "GM Petition Reader") PetList$ = OpenFile("Petition List.txt") NameCount% = 0 ;This will be added up for every repeat, total count will be amount of names in the list. DialogOutPut(PLayer, ChatBox, "Total names on petitions are as follows.", 230, 145, 23) Repeat EndRepeat = Eof(PetList) Nameinlist$ = ReadLine(PetList) DoEvents(250) ;EndRepeat = Eof(PetList) DialogOutPut(Player, ChatBox, + Nameinlist, 230, 145, 23) NameCount% = NameCount + 1 Until (EndRepeat = 1) NameCount% = NameCount - 1 ;Take 1 away since it counts 1 blank space. CloseFile(Nameinlist) CloseFile(PetList) DialogOutput(Player, ChatBox, "There is a total of " + NameCount + " Names in the list.", 230, 145, 23) DialogInPut(Player, ChatBox, "Close") CloseDialog(Player, ChatBox) Endif Else ;player is not a gm OutPut(Player, "You are not a gm.",255, 0, 0) Return Endif End Function